﻿using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdCompanyPreviewTest and is intended
    ///     to contain all TmdCompanyPreviewTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdCompanyPreviewTest
    {
        /// <summary>
        ///     A test for TmdCompanyPreview Constructor
        /// </summary>
        [TestMethod]
        public void TmdCompanyPreviewConstructorTest()
        {
            var target = new TmdCompanyPreview();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for LogoPath
        /// </summary>
        [TestMethod]
        public void LogoPathTest()
        {
            var target = new TmdCompanyPreview();
            string expected = Guid.NewGuid().ToString();
            target.LogoPath = expected;
            string actual = target.LogoPath;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Serialize & Deserialize
        /// </summary>
        [TestMethod]
        [DeploymentItem(@"..\..\TestData\companyPreview.json.txt")]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdCompanyPreview();
            var jsonContent = File.ReadAllText("companyPreview.json.txt");
            var actual = await target.DeserializeJson<TmdCompanyPreview>(jsonContent);

            Assert.AreEqual("/asdqdasgqa123qasdasda.jpg", actual.LogoPath);
            Assert.AreEqual("Screengame", actual.Name);
            Assert.AreEqual(10, actual.Id);
        }
    }
}